package com.dinzeer.sjapadder.event;

import com.dinzeer.legendreliclib.lib.util.slashblade.SlashBladeUtil;
import com.dinzeer.sjapadder.register.SjaSpecialEffectRegsitry;
import mods.flammpfeil.slashblade.capability.slashblade.ISlashBladeState;
import mods.flammpfeil.slashblade.event.SlashBladeEvent;
import mods.flammpfeil.slashblade.item.ItemSlashBlade;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber
public class NihilBxEvent {


    @SubscribeEvent
    public static void DoSlashTime(SlashBladeEvent.DoSlashEvent event){
        ISlashBladeState state=event.getSlashBladeState();
        if (state.getTranslationKey().equals("item.slashblade_addon.nihilbx")){
            if (!state.hasSpecialEffect(SjaSpecialEffectRegsitry.SoulDevouring.getId())&&state.getKillCount()>=3000){
                state.addSpecialEffect(SjaSpecialEffectRegsitry.SoulDevouring.getId());
            }
        }
    }
    @OnlyIn(Dist.CLIENT)
    @SubscribeEvent
    public static void SlashBladeToolTip(ItemTooltipEvent event){
        if (event.getItemStack().getItem() instanceof ItemSlashBlade){
          ISlashBladeState state=  SlashBladeUtil.getState(event.getItemStack());
            if (state.getTranslationKey().equals("item.slashblade_addon.nihilbx")){
          if (!state.hasSpecialEffect(SjaSpecialEffectRegsitry.SoulDevouring.getId())){
              event.getToolTip().add(Component.translatable("item.slashblade_addon.soul_devouring.tip").withStyle(ChatFormatting.DARK_RED));
          }
            }
        }
    }
}
